// pages/index/index.js


Page({
    
    /**
     * 页面的初始数据
     */
    data: {
        // 初代非云端轮播，
        // swiperItems:[
        //     {imageUrl:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Ftva1.sinaimg.cn%2Flarge%2F0032l8l0gy1gst74u4gljj60yi22o7mt02.jpg&refer=http%3A%2F%2Ftva1.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1659993781&t=39795a6b923b652fc3c3f123c82012b9',title:'轮播图1',
        //     config:[
        //         {title:"123",subtitle:"服务城市"},
        //         {title:"123",subtitle:"服务人数"},
        //         {title:"123",subtitle:"覆盖面积"}
        //     ]},
        //    {
        //        imageUrl:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbkimg.cdn.bcebos.com%2Fpic%2F7acb0a46f21fbe096b63ecaa792f1b338744ebf80774&refer=http%3A%2F%2Fbkimg.cdn.bcebos.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1660010048&t=3eb2d9f9f01a753f11f34a33d51ecd4c',title:'海浪',
        //        config:[
        //            {title:"234",subtitle:"服务人数"},
        //            {title:"234",subtitle:"服务人数"},
        //            {title:"234",subtitle:"服务人数"}
        //        ]
        //    },
        //    {imageUrl:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_source%2Fc6%2F04%2F1a%2Fc6041a9fbccdf051217fb50483cc2a4f.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1660010316&t=4bf51beb78921d43d178f7b9328a93c9',title:'标题3' ,  config:[
        //     {title:"123",subtitle:"服务城市"},
        //     {title:"123",subtitle:"服务人数"},
        //     {title:"123",subtitle:"覆盖面积"}
        // ]},
        
        //    {imageUrl:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.962.net%2Fup%2F2019-5%2F15586007992436292.gif&refer=http%3A%2F%2Fpic.962.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1660084417&t=69ece2d809704bd81f95e2e2cd3249aa',title:'皮什么卡丘?'},
        //    {imageUrl:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.962.net%2Fup%2F2019-5%2F15586007992436292.gif&refer=http%3A%2F%2Fpic.962.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1660084417&t=69ece2d809704bd81f95e2e2cd3249aa'}
        // ],
      
        swiperList:[],  
        currentSwiperIndex:0 
        
    },

    /**
     * 生命周期函数--监听页面加载
     */
   
  
    // bug
    // app.js只能设置到下一级，页面栈问题
    tiaoZhuan1(){
       wx.navigateTo({
         url: '../add',
       })
    },
    tiaoZhuan2(){
        wx.navigateTo({
          url: '../map2',
        })
    },
   
  
    onSwiperChange(e){
        
        const {current} = e.detail
        this.setData({
            currentSwiperIndex:current

        })
    },
     onLoad: function (options)  {
     
         this.db = wx.cloud.database()
         this._loadSwiper()
     },

     gotoProduct(e){
        if(e.currentTarget.dataset==null){
            return;
        }
        const{productId}=e.currentTarget.dataset
        wx.navigateTo({
            url:'/pages/product/index?id=${productId}',
        })
     },
     
     _loadSwiper(){
         this.db.collection('swiper').get().then(res=>{
          this.setData({
              swiperList:res.data
          })
         })
       
      
    },
    
    
    
    
    
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() { 

    }
})